﻿using Autodesk.AutoCAD.Colors;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _12注释样式
{
    public class Class1
    {
        [CommandMethod("DimStyleDemo")]
        public void DimStyleDemo()
        {
            Database db = HostApplicationServices.WorkingDatabase;
            ObjectId dimStyleId =  db.AddDimStyle("我的注释样式");

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                DimStyleTableRecord dstr = (DimStyleTableRecord)dimStyleId.GetObject(OpenMode.ForWrite);
                dstr.Dimclrd = Color.FromColorIndex(ColorMethod.ByAci, 1);
                
                trans.Commit();

               
            }
        }

        [CommandMethod("ShowDimStyleDemo")]
        public void ShowDimStyleDemo()
        {
            Database db = HostApplicationServices.WorkingDatabase;
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                DimStyleTable dst = (DimStyleTable)trans.GetObject(db.DimStyleTableId, OpenMode.ForRead);
                foreach (ObjectId item in dst)
                {
                    DimStyleTableRecord dstr = (DimStyleTableRecord)item.GetObject(OpenMode.ForRead);
                }
            }
        }
    }
}
